// pages/have/repair/repair.js
const app = getApp();
import { checkcertified } from '../../../api/api';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    nvabarData: {
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '一键报修 ', //导航栏 中间的标题
      img: "../../image/back.png"
    },
    text: '立即认证',
    click: true,
    imgUrl: app.globalData.imgUrl
  },

  bindViewTap: function () {
    if (!this.data.click) {
      return;
    }
    if (!app.globalData.hasLogin || !app.globalData.hasMobile) {
      wx.navigateTo({  url: '/pages/me/login/login' })
    }  else {
      wx.navigateTo({ url: '/pages/have/authentication/authentication' });
    }
  },

  onLoad: function (options) {
    app.showLoading();
    const data = { openid: app.globalData.openid }
    const that = this;
    checkcertified(data).then(res => {
      app.hideLoading();
      if (res.code === 0) {
        that.setData({
          text: '已认证',
          click: false
        })
      }
    })
  },

  onShow: function (options) {
    app.showLoading();
    const data = {
      openid: app.globalData.openid
    }
    const that = this;
    checkcertified(data).then(res => {
      app.hideLoading();
      if (res.code === 0) {
        that.setData({
          text: '已认证',
          click: false
        })
      }
    })
  }
})